Data Analysis on Brunei’s Climate (Temperature)

Author

Alvin Bong

1 Research Question

Climate change has been prevalent worldwide, causing adverse effects felt by all. It would be interesting to explore:

  • How has Brunei’s temperature evolved over time?
  • Is this consistent with global temperature trends?
  • How temperature varies by month?

2 Data Collection and Cleaning

2.1 Data Collection

The dataset is sourced from NASA POWER API using {nasapower} package in R, covering years 1981 to 2023.

Code
df <- get_power(
  community = "re",
  lonlat = c(114.9, 4.9),
  pars = c("T2M", "T2M_MAX", "T2M_MIN", "TS", "TS_MAX", "TS_MIN"),
  dates = c("1981-01-01", "2023-12-31"),
  temporal_api = "monthly"
)

write.csv(df, "brunei_temp.csv", row.names = FALSE)

2.2 Cleaning

df <- read_csv("brunei_temp.csv")
df <- df %>% 
    pivot_longer(cols = 5:16, names_to = "MONTH") %>% 
    select(-ANN, -LON, -LAT) %>% 
    spread(PARAMETER, value)
df$DATE <- ymd(paste(df$YEAR, df$MONTH, "01"))
df <- df %>% arrange(DATE)

t2m_ts <- ts(df$T2M, start = c(1981, 1), frequency = 12)

2.3 Variable of interest

NASA provides two temperature-related variables: T2M (temperature at 2 meters) and TS (surface temperature). A comparison shows that both are highly correlated, making one sufficient for analysis. Since T2M better represents the temperature experienced by a person, this project uses T2M. However, using TS would likely yield similar results.

Code
ggplot(df, aes(x = T2M, y = TS)) +
  geom_point() +
  geom_smooth(method = "lm", se = FALSE, color = "blue") +
  labs(
    title = "TS vs T2M",
    x = "T2M",
    y = "TS"
  ) +
  theme_minimal()

3 Findings

3.1 Trend Analysis

From the initial plot (Figure 1), surface temperature appears relatively stable over the years. However, applying linear regression estimates a gradual temperature increase of 0.018°C per year. While this may seem negligible, it amounts to approximately 0.9°C over a 50-year period.

Figure 1: Brunei BSB Monthly Temperature 1981-2023


lm_temp <- lm(T2M ~ YEAR, data = df)
summary(lm_temp)

Call:
lm(formula = T2M ~ YEAR, data = df)

Residuals:
     Min       1Q   Median       3Q      Max 
-1.58327 -0.34923  0.01707  0.39578  2.00782 

Coefficients:
             Estimate Std. Error t value Pr(>|t|)    
(Intercept) -8.987713   3.999351  -2.247    0.025 *  
YEAR         0.018083   0.001998   9.052   <2e-16 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 0.5631 on 514 degrees of freedom
Multiple R-squared:  0.1375,    Adjusted R-squared:  0.1358 
F-statistic: 81.94 on 1 and 514 DF,  p-value: < 2.2e-16


plot(decompose(t2m_ts))
Figure 2: Decomposition of T2M Time Series


Scholars argue that linear regression may not always be suitable for time series data, especially when strong stochastic trends or autocorrelation are present. However, our data exhibits stable seasonal cycles and randomness (Figure 2). Since a moving average is expected to produce a similar trend, we use linear regression for simplicity while acknowledging its limitations.

3.2 Extreme Events

From Figure 3, we observe temperature peaks in 1998 and 2023. This aligns with the El Niño cycle, indicating that Brunei is not immune to extreme weather events. Globally, both 1998 and 2023 were marked by extreme temperature anomalies, with both years experiencing record heat.

Code
# Aggregate time series by year (assuming monthly data)
t2m_agg <- aggregate(t2m_ts, FUN = mean)

# Convert to data frame for ggplot
df_t2m <- data.frame(
  Year = as.numeric(time(t2m_agg)),  # Extract time index
  Temperature = as.numeric(t2m_agg)  # Extract values
)

# Create ggplot
p <- ggplot(df_t2m, aes(x = Year, y = Temperature)) +
  geom_line(color = "blue", size = 1) +
  geom_point(color = "red", size = 2) +
  labs(title = "Average Yearly Temperature (T2M)",
       x = "Year",
       y = "Mean Temperature (°C)") +
  theme_minimal()

# Convert to interactive plot
ggplotly(p)
Figure 3

3.3 Month Distribution

The following is the temperature distribution by months over the 40-year period. We see that temperature is hotter in mid year and cools off towards year and and start of new year.

boxplot(t2m_ts ~ cycle(t2m_ts), names = month.abb, 
        xlab = NULL, ylab = "Temperature (°C)", 
        main = "Monthly Temperature Distribution")

4 Conclusion

This project can be summarised in three main points:

  • Temperature is gradually increasing in Brunei.

  • Brunei is not immune to El Niño effects. Extreme heat in 1998 & 2023 (aligning with global anomalies)

  • May is the hottest month in Brunei.

5 Acknowledgements

The author expresses gratitude to NASA POWER for the data used in the project.